app = new Vue({
	el: "#app",
	data() {
		return {
			flag :true,
			queryForm: {
				name: localStorage.getItem('USERNAME'),
				names: "",
				pageNo: 1, // 当前页码
				pagesize: 100, // 每页记录数
				pagesizes: [10, 20, 50, 100]
			},
			pagedatatemp: [], // 当前页结果集
			pagedata: [], // 当前页结果集
		}
	},
	methods: {
		test(item,index){
			var href = "../service/examination.html?testid=" + item.id
			window.location.href = href;
		},
		// 查询
		async query() {
			console.log(this.queryForm)
			try {
				let res = await axios.post('api/testpaperview/phonequerylist', this.queryForm);
				if (res.code === 200) {
					this.pagedata = res.data;
					this.pagetotal = res.total;


				} else {

				}
			} catch (e) {

			}
			console.log(this.pagedata)
			for(item in this.pagedata){
				if(this.pagedata[item].state=='进行中'&this.pagedata[item].score==''){
					this.flag =true;
				}else{
					this.flag=false;
				}
			}
		},
		// 初始化团队成员列表
		async initMembers() {
			try {
				let res = await axios.get('api/team/member/' + localStorage.getItem('USERID'));
				if (res.code === 200) {
					this.members = res.data;
					if (this.members.length > 0) {
						this.queryForm.userid = this.members[0].id;
					}
				} else {
					this.$message.error(res.message);
				}
			} catch (e) {
				this.$message.error('请求出错！', e.message);
			}
		}

	},
	async mounted() {
		this.initMembers();
		this.query();
	}
});
